﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace GA.Server.ApiInfo
{
    [Serializable]
    public class ApiItem
    {
        public string ItemName { get; private set; }
        public int Price { get; private set; }
        public int ProductionCost { get; private set; }
        public string Quality { get; private set; }
        public int Quantity { get; private set; }
        public string Skill { get; private set; }
        public string SkillGroup { get; private set; }
        public int SkillId { get; private set; }

        public ApiItem()
        {
        }

        public ApiItem(XmlReader reader)
        {
            while (!reader.EOF)
            {
                reader.Read();
                if (reader.NodeType == XmlNodeType.Element)
                {
                    string name = reader.Name;
                    string value = ApiXmlNode.GetValue(reader);
                    switch (name)
                    {
                        case "a:item_name": ItemName = value; break;
                        case "a:price": Price = value == null ? -1 : int.Parse(value); break;
                        case "a:production_cost": ProductionCost = value== null ? -1 : int.Parse(value); break;
                        case "a:quality": Quality = value; break;
                        case "a:quantity": Quantity = value == null ? -1 : int.Parse(value); break;
                        case "a:skill": Skill = value; break;
                        case "a:skill_group": SkillGroup = value; break;
                        case "a:skill_id": SkillId = value == null ? -1 : int.Parse(value); break;
                    }
                }
            }
        }
    }
}
